package com.spel.validate.util;

import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.aop.support.AopUtils;

/**
 * @title: AopUtils
 * @Author xu-xiang
 * @Date: 2024/2/1 14:27
 * @description:
 */
public class AopUtil {

    /**
     * 获取对象的最终代理proxy Class
     *
     * @param object 代理bean
     * @return proxy bean的class
     */
    public static Class<?> getUltimateProxyClass(Object object) {
        if (AopUtils.isAopProxy(object)) {
            return AopProxyUtils.ultimateTargetClass(object);
        }

        return object.getClass();
    }
}
